import java.io.File;
import javax.swing.JTextArea;

public class Module {
	private static JTextArea screen = null;

	public Module(int port) {
		super();
		ServerThread.instance().setPort(port);
	}

	public static JTextArea getScreen() {
		return screen;
	}

	public static void setScreen(JTextArea screen) {
		Module.screen = screen;
	}

	public void run() {
		ServerThread.instance().start();
		// Server started
	}

	public void send(String ip, int port, File file) {
		SendingThread sendingThread = new SendingThread(ip, port, file);
		sendingThread.run();
	}
	
	public static void writeToScreen(String string){
		if (screen != null) {
			screen.append(string
					+ "\n");
		} else {
			System.out.println(string);
		}
	}
}
